<?php




//根据ip获取地理信息
function getLocation($ip)
{
    $url = config('blog.location_api').$ip;
    $file = file_get_contents($url);
    $file = json_decode($file,true);
    $province = str_replace('省','',$file['data']['region']);
    $city = str_replace('市','',$file['data']['city']);
    return $province.'&nbsp;'.$city;
}

//图形验证码验证
function checkVerify($code, $id='')
{
	$Verify = new \Think\VerifyCode();
	return $Verify->check($code,$id);
}

//邮箱检测
function checkEmial($email)
{
	if ($emial) {
		$res = DB::table('user')->where('emial',$email)->select('email')->first();
		if ($res) {
			return true;
		}
		return false;
	}
}

//用户密码加密
function codePass($password)
{
	if ($password) {
		return md5($password.config('blog.salt'));
	}
}

//验证用户密码
function getMd5Pss($where)
{
	if ($password) {
		$pass = DB::table('user')->where($where)->select('password','username','user_id')->first();
		if ($pass) {
			return $pass;
		}
		return false;
	}
}

//邮件随机激活码
function emailCode()
{
	$str = 'qwertyuioplkjhgfdsazxcvbnm1234567890';
	return substr(str_shuffle($str), 16);
}